<template>
  <section>
    <el-button-group>
      <el-button
        v-permission="installPermissions.permissions.role.grantRolePermission"
        size="mini"
        type="primary"
        @click="handleGrant"
        icon="fa fa-superpowers"
      >
        设置权限
      </el-button>
      <el-button
        v-permission="installPermissions.permissions.role.edit"
        size="mini"
        type="primary"
        @click="handleEdit"
        icon="fa fa-edit"
      >
        编辑
      </el-button>
      <el-button
        v-permission="installPermissions.permissions.role.del"
        size="mini"
        type="primary"
        @click="handleDelete"
        icon="fa fa-trash-o"
      >
        删除
      </el-button>
    </el-button-group>
  </section>
</template>
<style>
</style>
<script>
export default {
  props: {
    row: {
      type: Object,
      default: function() {
        return {};
      }
    },
    col: {
      type: Object,
      default: function() {
        return {};
      }
    }
  },
  methods: {
    handleDelete() {
      this.$confirm("此操作将永久删除该角色, 是否继续?", "删除提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        this.$api.role.delete(this.row.id, () => {
          this.$message({
            type: "success",
            message: "删除角色成功",
            onClose: () => {
              this.$emit("deleteDone", this.row);
            }
          });
        });
      });
    },
    handleEdit() {
      this.$emit("editRow", this.row);
    },
    handleGrant() {
      this.$emit("grantShow", this.row);
    }
  }
};
</script>
